package com.controller;

import com.alibaba.fastjson.JSON;
import com.entity.PostsEntity;
import com.service.PostsService;
import com.service.UserService;
import com.service.serviceImpl.PostsServiceImpl;
import com.service.serviceImpl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class PostsServlet extends HttpServlet {
    private PostsService postsService = new PostsServiceImpl();
    private UserService userService = new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<PostsEntity> postsEntities = postsService.postsList();
        String s = JSON.toJSONString(postsEntities);
        resp.getWriter().write(s);
    }
}
